<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="author" content="lcx">
    <title>JQ版轮播图</title>
    <script src="jquery-3.1.1.js"></script>
    <style>
        ul,
        li {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        
        #box {
            width: 520px;
            height: 280px;
            margin: 100px auto;
            position: relative;
        }
        
        #box .list li {
            position: absolute;
            top: 0;
            left: 0;
            display: none;
        }
        
        #box .list li.current {
            display: block;
        }
        
        #box .count {
            position: absolute;
            right: 10px;
            bottom: 10px;
        }
        
        #box .count li {
            float: left;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            background-color: #fa0;
            text-align: center;
            line-height: 20px;
            margin-left: 10px;
            color: #fff;
            opacity: 0.8;
            cursor: pointer;
        }
        
        #box .count li.current {
            background-color: #f60;
            opacity: 1;
        }
    </style>
</head>

<body>
    <div id="box">
        <ul class="list">
            <li class="current"><img src="img/1.jpg" alt=""></li>
            <li><img src="img/2.jpg" alt=""></li>
            <li><img src="img/3.jpg" alt=""></li>
            <li><img src="img/4.jpg" alt=""></li>
            <li><img src="img/5.jpg" alt=""></li>
        </ul>
        <ul class="count">
            <li class="current">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>
    </div>
</body>

</html>
<script>
    $(function () {
        var index = 0;
        var timer = null
        timer = setInterval(auto, 1000);
        function auto() {
            index++;
            if (index == $('#box .list li').length) {
                index = 0;
            }
            $('#box .list li').eq(index).show().siblings().hide();
        }


        $('#box .count li').each(function (index) {
            var num = $(this).index()
            var ul = $($('#box .list li')[num])
            $(this).mouseenter(function () {
                $(this).addClass('current').siblings().removeClass('current')
                ul.show().siblings().hide();
            })
        })

        $('#box').mouseover(function () {
            clearInterval(timer);
        })
        $('#box').mouseleave(function(){
            timer = setInterval(auto, 1000);
        })
    })

</script>